package com.sm.honkon.ui.adapter

import android.graphics.Color
import android.widget.TextView
import androidx.lifecycle.Transformations.map
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.sm.honkon.R
import com.sm.honkon.data.bean.HandlerEntity
import com.sm.honkon.databinding.ItemHandleBinding

class HandlerAdapter(
    data: MutableList<HandlerEntity> = arrayListOf(),
    layoutResIdRes: Int = R.layout.item_handle,
    val checkList: MutableList<Boolean> = arrayListOf()
) :
    BaseQuickAdapter<HandlerEntity, BaseDataBindingHolder<ItemHandleBinding>>(
        layoutResIdRes,
        data
    ) {


    override fun convert(helper: BaseDataBindingHolder<ItemHandleBinding>, item: HandlerEntity) {
        item.let {
            helper.apply {
                getView<TextView>(R.id.tv_number).text = it.uidShow()
                dataBinding?.tvNumber?.isSelected = checkList[layoutPosition]
                getView<TextView>(R.id.tv_worknum).text = it.workId
                getView<TextView>(R.id.tv_name).text = it.name
                getView<TextView>(R.id.tv_sex).text = it.sexShow
                getView<TextView>(R.id.tv_phone).text = it.mobile
                getView<TextView>(R.id.tv_technical).text = it.medical_official
                getView<TextView>(R.id.tv_creat_time).text = it.crateTime
                getView<TextView>(R.id.tv_status).apply {
                    if (it.status == 0) {
                        text = "正常"
                        setTextColor(context.resources.getColor(R.color.ff333333))
                    } else {
                        text = "禁用"
                        setTextColor(Color.RED)
                    }
                }
                getView<TextView>(R.id.tv_psw).text = it.password

            }
        }
    }

}